package leecode

func checkDistances(s string, distance []int) bool {
	hashMap := make(map[byte]int) //记录字母出现的最后下标
	arr := []byte(s)
	for index, str := range arr {
		hashMap[str] = index
	}
	// 97
	for index, str := range arr {
		if value, ok := hashMap[str]; ok {
			if value > index {
				if distance[str-97] != value-index-1 {
					return false
				}
			}
		}
	}
	return true
}
